CREATE TABLE [dbo].[DnnProduct_CoreMessaging_MessageRecipients]
(
[RecipientID] [int] NOT NULL IDENTITY(1, 1),
[MessageID] [int] NOT NULL,
[UserID] [int] NOT NULL,
[Read] [bit] NOT NULL CONSTRAINT [DF__DnnProduct__Read__2843D2B2] DEFAULT ((0)),
[Archived] [bit] NOT NULL CONSTRAINT [DF__DnnProduc__Archi__2937F6EB] DEFAULT ((0)),
[EmailSent] [bit] NOT NULL CONSTRAINT [DF__DnnProduc__Email__2A2C1B24] DEFAULT ((0)),
[EmailSentDate] [datetime] NULL,
[EmailSchedulerInstance] [uniqueidentifier] NULL,
[CreatedByUserID] [int] NULL,
[CreatedOnDate] [datetime] NULL,
[LastModifiedByUserID] [int] NULL,
[LastModifiedOnDate] [datetime] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[DnnProduct_CoreMessaging_MessageRecipients] ADD CONSTRAINT [PK_DnnProduct_CoreMessaging_MessageRecipients] PRIMARY KEY CLUSTERED  ([RecipientID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_DnnProduct_CoreMessaging_MessageRecipients_UserID] ON [dbo].[DnnProduct_CoreMessaging_MessageRecipients] ([UserID], [Read] DESC, [Archived]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[DnnProduct_CoreMessaging_MessageRecipients] ADD CONSTRAINT [FK_DnnProduct_CoreMessaging_MessageRecipients_DnnProduct_CoreMessaging_Messages] FOREIGN KEY ([MessageID]) REFERENCES [dbo].[DnnProduct_CoreMessaging_Messages] ([MessageID]) ON DELETE CASCADE
GO
